/*
 * Copyright (c) 2013-2018 上海汇数数据. All rights reserved.
 * @(#) DefaultOpsOutVO.java 2018-08-08 23:23
 */

package cn.jh.common.core.ret;

import com.google.common.base.MoreObjects;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.io.Serializable;
import java.util.List;
import java.util.Objects;


/**
 * @author Fuchun
 * @since 1.0
 */
class DefaultOpsOutVO extends OpsOutVO {

    private static final long serialVersionUID = 1L;

    private final String code;
    private final String message;
    private final String description;
    private final Serializable data;
    private final List<FieldError> errors;

    DefaultOpsOutVO(
            @NotNull String code, @Nullable String message, @Nullable String description,
            @Nullable Serializable data, @Nullable List<FieldError> errors) {
        this.code = code;
        this.message = message;
        this.description = description;
        this.data = data;
        this.errors = errors;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Nullable
    @Override
    public String getMessage() {
        return message;
    }

    @Nullable
    @Override
    public String getDescription() {
        return description;
    }

    @Nullable
    @Override
    public Serializable getData() {
        return data;
    }

    @Nullable
    @Override
    public List<FieldError> getErrors() {
        return errors;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof DefaultOpsOutVO)) return false;
        DefaultOpsOutVO that = (DefaultOpsOutVO) o;
        return Objects.equals(code, that.code) &&
                Objects.equals(message, that.message) &&
                Objects.equals(description, that.description) &&
                Objects.equals(data, that.data) &&
                Objects.equals(errors, that.errors);
    }

    @Override
    public int hashCode() {
        return Objects.hash(code, message, description, data, errors);
    }

    @Override
    public String toString() {
        return MoreObjects.toStringHelper(this)
                .add("code", code)
                .add("message", message)
                .add("description", description)
                .add("data", data)
                .add("errors", errors)
                .toString();
    }
}
